import java.util.Stack;

class MinStack {
    Stack<Integer> Stack;
   Stack<Integer> minStack;
    public MinStack() {
     this.minStack = new Stack<>();
     this.Stack = new Stack<>();
    }

    public void push(int val) {
        Stack.push(val);
        if(minStack.empty()){
            minStack.push(val);
        }else if(val <= minStack.peek()){
            minStack.push(val);
        }
    }

    public void pop() {
      int val =  Stack.pop();
      if(val == minStack.peek()){
          minStack.pop();
      }
    }

    public int top() {
      return Stack.peek();
    }

    public int getMin() {
       return minStack.peek();
    }
}